#include <stdio.h>
#include <flgrCoreData.h>
#include <flgrCoreDataIO.h>
#include <flgrCoreCopy.h>
#include <flgrCoreGeometry.h>
#include "../macro.h"

/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry1d_line(dtype)			\
							\
  dtype rawref[]={0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0};	\
							\
  FLGR_Data1D *dat, *dat_str, *datref;			\
  FLGR_Ret ret;						\
  dtype val=1;						\
  FLGR_Vector *vec;					\
							\
  datref  = flgr1d_create_##dtype(11,1,FLGR_NO_SHAPE);	\
  dat     = flgr1d_create_##dtype(11,1,FLGR_NO_SHAPE);	\
  dat_str = flgr1d_create_##dtype(11,1,FLGR_NO_SHAPE);	\
							\
  vec = flgr_vector_create(datref->spp,datref->type);	\
  flgr_vector_populate_from_scalar_##dtype(vec,val);	\
							\
  flgr1d_import_raw_ptr(datref,rawref);			\
  flgr1d_clear_all(dat);				\
  flgr1d_clear_all(dat_str);				\
							\
  ret = flgr1d_draw_line_ptr(dat,3,3,vec);		\
  check_and_display_data1d(datref,dat,ret);		\
							\
  ret = flgr1d_draw_line_str(dat_str,3,3,"1");		\
  check_and_display_data1d(datref,dat_str,ret);		\
							\
							\
  flgr1d_destroy(datref);				\
  flgr1d_destroy(dat);					\
  flgr1d_destroy(dat_str);				\
  flgr_vector_destroy(vec);				\
  return 2

int testgeometry1d_line_fgBIT(void) {
  tstGeometry1d_line(fgBIT);
}
int testgeometry1d_line_fgUINT8(void) {
  tstGeometry1d_line(fgUINT8);
}
int testgeometry1d_line_fgUINT16(void) {
  tstGeometry1d_line(fgUINT16);
}
int testgeometry1d_line_fgUINT32(void) {
  tstGeometry1d_line(fgUINT32);
}
int testgeometry1d_line_fgINT8(void) {
  tstGeometry1d_line(fgINT8);
}
int testgeometry1d_line_fgINT16(void) {
  tstGeometry1d_line(fgINT16);
}
int testgeometry1d_line_fgINT32(void) {
  tstGeometry1d_line(fgINT32);
}
int testgeometry1d_line_fgFLOAT32(void) {
  tstGeometry1d_line(fgFLOAT32);
}
int testgeometry1d_line_fgFLOAT64(void) {
  tstGeometry1d_line(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry1d_spp3_line(dtype)			\
							\
  dtype rawref[]={0,0,0,				\
		  0,0,0,				\
		  0,0,0,				\
		  1,1,1,				\
		  1,1,1,				\
		  1,1,1,				\
		  0,0,0,				\
		  0,0,0,				\
		  0,0,0,				\
		  0,0,0,				\
		  0,0,0};				\
							\
  FLGR_Data1D *dat, *dat_str, *datref;			\
  FLGR_Ret ret;						\
  dtype val=1;						\
  FLGR_Vector *vec;					\
							\
  datref  = flgr1d_create_##dtype(11,3,FLGR_NO_SHAPE);	\
  dat     = flgr1d_create_##dtype(11,3,FLGR_NO_SHAPE);	\
  dat_str = flgr1d_create_##dtype(11,3,FLGR_NO_SHAPE);	\
							\
  vec = flgr_vector_create(datref->spp,datref->type);	\
  flgr_vector_populate_from_scalar_##dtype(vec,val);	\
							\
  flgr1d_import_raw_ptr(datref,rawref);			\
  flgr1d_clear_all(dat);				\
  flgr1d_clear_all(dat_str);				\
							\
  ret = flgr1d_draw_line_ptr(dat,3,3,vec);		\
  check_and_display_data1d(datref,dat,ret);		\
							\
  ret = flgr1d_draw_line_str(dat_str,3,3,"1 1 1");	\
  check_and_display_data1d(datref,dat_str,ret);		\
							\
  flgr1d_destroy(datref);				\
  flgr1d_destroy(dat);					\
  flgr1d_destroy(dat_str);				\
  flgr_vector_destroy(vec);				\
  return 2

int testgeometry1d_spp3_line_fgBIT(void) {
  tstGeometry1d_spp3_line(fgBIT);
}
int testgeometry1d_spp3_line_fgUINT8(void) {
  tstGeometry1d_spp3_line(fgUINT8);
}
int testgeometry1d_spp3_line_fgUINT16(void) {
  tstGeometry1d_spp3_line(fgUINT16);
}
int testgeometry1d_spp3_line_fgUINT32(void) {
  tstGeometry1d_spp3_line(fgUINT32);
}
int testgeometry1d_spp3_line_fgINT8(void) {
  tstGeometry1d_spp3_line(fgINT8);
}
int testgeometry1d_spp3_line_fgINT16(void) {
  tstGeometry1d_spp3_line(fgINT16);
}
int testgeometry1d_spp3_line_fgINT32(void) {
  tstGeometry1d_spp3_line(fgINT32);
}
int testgeometry1d_spp3_line_fgFLOAT32(void) {
  tstGeometry1d_spp3_line(fgFLOAT32);
}
int testgeometry1d_spp3_line_fgFLOAT64(void) {
  tstGeometry1d_spp3_line(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Point(dtype)					\
									\
  dtype rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 1};			\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_point_ptr(img,9,7,vec);				\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_point_str(img_str,9,7,"1");				\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_point_fgBIT(void) {
  tstGeometry_Point(fgBIT);
}
int testgeometry_point_fgUINT8(void) {
  tstGeometry_Point(fgUINT8);
}
int testgeometry_point_fgUINT16(void) {
  tstGeometry_Point(fgUINT16);
}
int testgeometry_point_fgUINT32(void) {
  tstGeometry_Point(fgUINT32);
}
int testgeometry_point_fgINT8(void) {
  tstGeometry_Point(fgINT8);
}
int testgeometry_point_fgINT16(void) {
  tstGeometry_Point(fgINT16);
}
int testgeometry_point_fgINT32(void) {
  tstGeometry_Point(fgINT32);
}
int testgeometry_point_fgFLOAT32(void) {
  tstGeometry_Point(fgFLOAT32);
}
int testgeometry_point_fgFLOAT64(void) {
  tstGeometry_Point(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Point_spp2(dtype)					\
									\
  dtype rawref[]={0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,	\
		  0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,1};	\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,2,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,2,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,2,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_point_ptr(img,9,7,vec);				\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_point_str(img_str,9,7,"1 1");			\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_point_spp2_fgBIT(void) {
  tstGeometry_Point_spp2(fgBIT);
}
int testgeometry_point_spp2_fgUINT8(void) {
  tstGeometry_Point_spp2(fgUINT8);
}
int testgeometry_point_spp2_fgUINT16(void) {
  tstGeometry_Point_spp2(fgUINT16);
}
int testgeometry_point_spp2_fgUINT32(void) {
  tstGeometry_Point_spp2(fgUINT32);
}
int testgeometry_point_spp2_fgINT8(void) {
  tstGeometry_Point_spp2(fgINT8);
}
int testgeometry_point_spp2_fgINT16(void) {
  tstGeometry_Point_spp2(fgINT16);
}
int testgeometry_point_spp2_fgINT32(void) {
  tstGeometry_Point_spp2(fgINT32);
}
int testgeometry_point_spp2_fgFLOAT32(void) {
  tstGeometry_Point_spp2(fgFLOAT32);
}
int testgeometry_point_spp2_fgFLOAT64(void) {
  tstGeometry_Point_spp2(fgFLOAT64);
}

/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Horizontal_Line(dtype)				\
									\
  dtype rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 1, 1, 1, 1, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0};			\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_horizontal_line_ptr(img,1,1,5,vec);			\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_horizontal_line_str(img_str,1,1,5,"1");		\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_horizontal_line_fgBIT(void) {
  tstGeometry_Horizontal_Line(fgBIT);
}
int testgeometry_horizontal_line_fgUINT8(void) {
  tstGeometry_Horizontal_Line(fgUINT8);
}
int testgeometry_horizontal_line_fgUINT16(void) {
  tstGeometry_Horizontal_Line(fgUINT16);
}
int testgeometry_horizontal_line_fgUINT32(void) {
  tstGeometry_Horizontal_Line(fgUINT32);
}
int testgeometry_horizontal_line_fgINT8(void) {
  tstGeometry_Horizontal_Line(fgINT8);
}
int testgeometry_horizontal_line_fgINT16(void) {
  tstGeometry_Horizontal_Line(fgINT16);
}
int testgeometry_horizontal_line_fgINT32(void) {
  tstGeometry_Horizontal_Line(fgINT32);
}
int testgeometry_horizontal_line_fgFLOAT32(void) {
  tstGeometry_Horizontal_Line(fgFLOAT32);
}
int testgeometry_horizontal_line_fgFLOAT64(void) {
  tstGeometry_Horizontal_Line(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Vertical_Line(dtype)				\
									\
  dtype rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0};			\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_vertical_line_ptr(img,1,1,5,vec);			\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_vertical_line_str(img_str,1,1,5,"1");		\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_vertical_line_fgBIT(void) {
  tstGeometry_Vertical_Line(fgBIT);
}
int testgeometry_vertical_line_fgUINT8(void) {
  tstGeometry_Vertical_Line(fgUINT8);
}
int testgeometry_vertical_line_fgUINT16(void) {
  tstGeometry_Vertical_Line(fgUINT16);
}
int testgeometry_vertical_line_fgUINT32(void) {
  tstGeometry_Vertical_Line(fgUINT32);
}
int testgeometry_vertical_line_fgINT8(void) {
  tstGeometry_Vertical_Line(fgINT8);
}
int testgeometry_vertical_line_fgINT16(void) {
  tstGeometry_Vertical_Line(fgINT16);
}
int testgeometry_vertical_line_fgINT32(void) {
  tstGeometry_Vertical_Line(fgINT32);
}
int testgeometry_vertical_line_fgFLOAT32(void) {
  tstGeometry_Vertical_Line(fgFLOAT32);
}
int testgeometry_vertical_line_fgFLOAT64(void) {
  tstGeometry_Vertical_Line(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Line(dtype)						\
									\
  dtype rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 1, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 1, 1, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 1, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 1, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 1, 1, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 1};			\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_line_ptr(img,1,1,9,7,vec);				\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_line_str(img_str,1,1,9,7,"1");			\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_line_fgBIT(void) {
  tstGeometry_Line(fgBIT);
}
int testgeometry_line_fgUINT8(void) {
  tstGeometry_Line(fgUINT8);
}
int testgeometry_line_fgUINT16(void) {
  tstGeometry_Line(fgUINT16);
}
int testgeometry_line_fgUINT32(void) {
  tstGeometry_Line(fgUINT32);
}
int testgeometry_line_fgINT8(void) {
  tstGeometry_Line(fgINT8);
}
int testgeometry_line_fgINT16(void) {
  tstGeometry_Line(fgINT16);
}
int testgeometry_line_fgINT32(void) {
  tstGeometry_Line(fgINT32);
}
int testgeometry_line_fgFLOAT32(void) {
  tstGeometry_Line(fgFLOAT32);
}
int testgeometry_line_fgFLOAT64(void) {
  tstGeometry_Line(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Rectangle(dtype)					\
									\
  dtype rawref[]={1, 1, 1, 1, 0, 0, 0, 0, 0, 0,				\
		  1, 0, 0, 1, 0, 0, 0, 0, 0, 0,				\
		  1, 0, 0, 1, 0, 0, 0, 0, 0, 0,				\
		  1, 1, 1, 1, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 0, 0, 0, 0, 0, 0, 0, 0, 0};			\
									\
  dtype rawref2[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 1, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0};			\
									\
  FLGR_Data2D *img, *img_str, *imgref, *imgref2;			\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  imgref2 = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_import_raw_ptr(imgref2,rawref2);				\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_rectangle_ptr(img,0,0,4,4,vec);			\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_rectangle_str(img_str,0,0,4,4,"1");			\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_rectangle_ptr(img,4,3,1,1,vec);			\
  check_and_display_data2d(imgref2,img,ret);				\
  ret = flgr2d_draw_rectangle_str(img_str,4,3,1,1,"1");			\
  check_and_display_data2d(imgref2,img_str,ret);			\
									\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(imgref2);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_rectangle_fgBIT(void) {
  tstGeometry_Rectangle(fgBIT);
}
int testgeometry_rectangle_fgUINT8(void) {
  tstGeometry_Rectangle(fgUINT8);
}
int testgeometry_rectangle_fgUINT16(void) {
  tstGeometry_Rectangle(fgUINT16);
}
int testgeometry_rectangle_fgUINT32(void) {
  tstGeometry_Rectangle(fgUINT32);
}
int testgeometry_rectangle_fgINT8(void) {
  tstGeometry_Rectangle(fgINT8);
}
int testgeometry_rectangle_fgINT16(void) {
  tstGeometry_Rectangle(fgINT16);
}
int testgeometry_rectangle_fgINT32(void) {
  tstGeometry_Rectangle(fgINT32);
}
int testgeometry_rectangle_fgFLOAT32(void) {
  tstGeometry_Rectangle(fgFLOAT32);
}
int testgeometry_rectangle_fgFLOAT64(void) {
  tstGeometry_Rectangle(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Filled_Rectangle(dtype)				\
									\
  dtype rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1,				\
		  0, 1, 1, 1, 1, 1, 1, 1, 1, 1};			\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_draw_filled_rectangle_str(img,0,0,10,8,"0");			\
  flgr2d_draw_filled_rectangle_str(img_str,0,0,10,8,"0");		\
									\
  ret = flgr2d_draw_filled_rectangle_ptr(img,1,1,9,7,vec);		\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_filled_rectangle_str(img_str,1,1,9,7,"1");		\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_filled_rectangle_fgBIT(void) {
  tstGeometry_Filled_Rectangle(fgBIT);
}
int testgeometry_filled_rectangle_fgUINT8(void) {
  tstGeometry_Filled_Rectangle(fgUINT8);
}
int testgeometry_filled_rectangle_fgUINT16(void) {
  tstGeometry_Filled_Rectangle(fgUINT16);
}
int testgeometry_filled_rectangle_fgUINT32(void) {
  tstGeometry_Filled_Rectangle(fgUINT32);
}
int testgeometry_filled_rectangle_fgINT8(void) {
  tstGeometry_Filled_Rectangle(fgINT8);
}
int testgeometry_filled_rectangle_fgINT16(void) {
  tstGeometry_Filled_Rectangle(fgINT16);
}
int testgeometry_filled_rectangle_fgINT32(void) {
  tstGeometry_Filled_Rectangle(fgINT32);
}
int testgeometry_filled_rectangle_fgFLOAT32(void) {
  tstGeometry_Filled_Rectangle(fgFLOAT32);
}
int testgeometry_filled_rectangle_fgFLOAT64(void) {
  tstGeometry_Filled_Rectangle(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Circle(dtype)					\
									\
  dtype rawref[]={  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,		\
		    0,  0,  0,  1,  1,  1,  0,  0,  0,  0,		\
		    0,  0,  1,  0,  0,  0,  1,  0,  0,  0,		\
		    0,  1,  0,  0,  0,  0,  0,  1,  0,  0,		\
		    0,  1,  0,  0,  0,  0,  0,  1,  0,  0,		\
		    0,  1,  0,  0,  0,  0,  0,  1,  0,  0,		\
		    0,  0,  1,  0,  0,  0,  1,  0,  0,  0,		\
		    0,  0,  0,  1,  1,  1,  0,  0,  0,  0};		\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_draw_filled_rectangle_str(img,0,0,10,8,"0");			\
  flgr2d_draw_filled_rectangle_str(img_str,0,0,10,8,"0");		\
									\
  ret = flgr2d_draw_circle_ptr(img,4,4,3,vec);				\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_circle_str(img_str,4,4,3,"1");			\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_circle_fgBIT(void) {
  tstGeometry_Circle(fgBIT);
}
int testgeometry_circle_fgUINT8(void) {
  tstGeometry_Circle(fgUINT8);
}
int testgeometry_circle_fgUINT16(void) {
  tstGeometry_Circle(fgUINT16);
}
int testgeometry_circle_fgUINT32(void) {
  tstGeometry_Circle(fgUINT32);
}
int testgeometry_circle_fgINT8(void) {
  tstGeometry_Circle(fgINT8);
}
int testgeometry_circle_fgINT16(void) {
  tstGeometry_Circle(fgINT16);
}
int testgeometry_circle_fgINT32(void) {
  tstGeometry_Circle(fgINT32);
}
int testgeometry_circle_fgFLOAT32(void) {
  tstGeometry_Circle(fgFLOAT32);
}
int testgeometry_circle_fgFLOAT64(void) {
  tstGeometry_Circle(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Disc(dtype)						\
									\
  dtype rawref[]={  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,		\
		    0,  0,  0,  1,  1,  1,  0,  0,  0,  0,		\
		    0,  0,  1,  1,  1,  1,  1,  0,  0,  0,		\
		    0,  1,  1,  1,  1,  1,  1,  1,  0,  0,		\
		    0,  1,  1,  1,  1,  1,  1,  1,  0,  0,		\
		    0,  1,  1,  1,  1,  1,  1,  1,  0,  0,		\
		    0,  0,  1,  1,  1,  1,  1,  0,  0,  0,		\
		    0,  0,  0,  1,  1,  1,  0,  0,  0,  0};		\
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,1,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_disc_ptr(img,4,4,3,vec);				\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_disc_str(img_str,4,4,3,"1");			\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_disc_fgBIT(void) {
  tstGeometry_Disc(fgBIT);
}
int testgeometry_disc_fgUINT8(void) {
  tstGeometry_Disc(fgUINT8);
}
int testgeometry_disc_fgUINT16(void) {
  tstGeometry_Disc(fgUINT16);
}
int testgeometry_disc_fgUINT32(void) {
  tstGeometry_Disc(fgUINT32);
}
int testgeometry_disc_fgINT8(void) {
  tstGeometry_Disc(fgINT8);
}
int testgeometry_disc_fgINT16(void) {
  tstGeometry_Disc(fgINT16);
}
int testgeometry_disc_fgINT32(void) {
  tstGeometry_Disc(fgINT32);
}
int testgeometry_disc_fgFLOAT32(void) {
  tstGeometry_Disc(fgFLOAT32);
}
int testgeometry_disc_fgFLOAT64(void) {
  tstGeometry_Disc(fgFLOAT64);
}







/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGeometry_Disc_spp9(dtype)					\
									\
  dtype rawref[]={  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0, \
		    0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,1,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0}; \
									\
  FLGR_Data2D *img, *img_str, *imgref;					\
  FLGR_Ret ret;								\
  dtype val=1;								\
  FLGR_Vector *vec;							\
									\
  imgref  = flgr2d_create_##dtype(8,10,9,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img     = flgr2d_create_##dtype(8,10,9,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
  img_str = flgr2d_create_##dtype(8,10,9,FLGR_NO_SHAPE,FLGR_NO_CONNEX);	\
									\
									\
  vec = flgr_vector_create(imgref->spp,imgref->type);			\
  flgr_vector_populate_from_scalar_##dtype(vec,val);			\
									\
  flgr2d_import_raw_ptr(imgref,rawref);					\
  flgr2d_clear_all(img);						\
  flgr2d_clear_all(img_str);						\
									\
  ret = flgr2d_draw_disc_ptr(img,4,4,3,vec);				\
  check_and_display_data2d(imgref,img,ret);				\
  ret = flgr2d_draw_disc_str(img_str,4,4,3,"1 1 1 1 1 1 1 1 1");	\
  check_and_display_data2d(imgref,img_str,ret);				\
									\
									\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
  flgr2d_destroy(img_str);						\
  flgr_vector_destroy(vec);						\
									\
  return 2

int testgeometry_disc_spp9_fgBIT(void) {
  tstGeometry_Disc_spp9(fgBIT);
}
int testgeometry_disc_spp9_fgUINT8(void) {
  tstGeometry_Disc_spp9(fgUINT8);
}
int testgeometry_disc_spp9_fgUINT16(void) {
  tstGeometry_Disc_spp9(fgUINT16);
}
int testgeometry_disc_spp9_fgUINT32(void) {
  tstGeometry_Disc_spp9(fgUINT32);
}
int testgeometry_disc_spp9_fgINT8(void) {
  tstGeometry_Disc_spp9(fgINT8);
}
int testgeometry_disc_spp9_fgINT16(void) {
  tstGeometry_Disc_spp9(fgINT16);
}
int testgeometry_disc_spp9_fgINT32(void) {
  tstGeometry_Disc_spp9(fgINT32);
}
int testgeometry_disc_spp9_fgFLOAT32(void) {
  tstGeometry_Disc_spp9(fgFLOAT32);
}
int testgeometry_disc_spp9_fgFLOAT64(void) {
  tstGeometry_Disc_spp9(fgFLOAT64);
}

